/*
 * @Author: huangxuzhong
 * @Date: 2021-09-28 11:38:43
 * @LastEditTime: 2024-07-04
 * @LastEditors: Tommy Chen
 * @Description: 公用校验函数
 * @FilePath: /macc.admin.vue/src/utils/validateTools.js
 */
import { i18nRender } from '@/locales';
const ValiDateTools = {
  //校验设备名称
  checkAliasName(value, maxLength) {
    if (!/^[\w\u4E00-\u9FA5\-@#.]+$/.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.inputFormat'),
      };
    }
    const strByteLen = value.replace(/[^\x00-\xff]/g, '|||').length;
    let len = maxLength || 64;

    if (strByteLen < 1 || strByteLen > len) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatLen', { n: len }),
      };
    }

    return { result: true };
  },
  //校验设备备注
  checkRemark(value, maxLength) {
    if (/[*?#/(){}]/.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule1'),
      };
    }
    const strByteLen = value.replace(/[^\x00-\xff]/g, '|||').length;
    let len = maxLength || 64;

    if (strByteLen < 1 || strByteLen > len) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatLen', { n: len }),
      };
    }

    return { result: true };
  },

  //校验字符长度（1个中文3个字符）
  checkStrLength(value, min = 1, max = 64) {
    const strByteLen = value.replace(/[^\x00-\xff]/g, '|||').length;
    if (strByteLen < min || strByteLen > max) {
      return {
        result: false,
        msg: i18nRender('validateTools.lenRule', { min, max }),
      };
    }
    return { result: true };
  },
  /**
   *
   * 校验分组名称
   * @param {*} value
   * @param {boolean} [vip=false] 2023-04-23 添加对Vip用户判断
   * @returns
   */
  checkGroupName(value, vip = false) {
    if (!/^[\w\-\s@#&\u4e00-\u9fa5\u0800-\u4e00.]+$/.test(value)) {
      return {
        result: false,
        msg: vip
          ? i18nRender('validateTools.formatRule2')
          : i18nRender('validateTools.formatRule2Vip'),
      };
    }

    if (vip) {
      if (value.length > 64) {
        return {
          result: false,
          msg: i18nRender('validateTools.formatRule3Vip'),
        };
      } else {
        return { result: true };
      }
    } else {
      const len = value.replace(/[^\x00-\xff]/g, '|||').length;
      if (/\s/.test(value) && len <= 30) {
        return { result: true };
      } else if (!/\s/.test(value) && len <= 32) {
        return { result: true };
      } else {
        return {
          result: false,
          msg: i18nRender('validateTools.formatRule3'),
        };
      }
    }
  },
  /**
   * 校验SSID名称
   */
  checkSsidName(str) {
    if (!/^[\w\-\s@#&\u4e00-\u9fa5\u0800-\u4e00.]+$/.test(str)) {
      return { result: false, msg: i18nRender('wirelessConfig.entercomfirm') };
    }
    const len = str.replace(/[^\x00-\xff]/g, '|||').length;
    if (/\s/.test(str) && len <= 30) {
      return { result: true };
    } else if (!/\s/.test(str) && len <= 32) {
      return { result: true };
    } else {
      return { result: false, msg: i18nRender('wirelessConfig.enterencod') };
    }
  },
  /**
   * 验证是否是Ipv4或者IpV6
   * @param {*} str
   * @returns
   */
  checkIpv4OrIpv6(str) {
    const regExp =
      /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$/;
    return regExp.test(str);
  },
  /**
   * 验证IPv6格式
   * @param {*} str
   * @returns
   */
  isIPv6: function (str) {
    var ipv6 =
      /^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$/;
    return ipv6.test(str);
  },
  /**
   * 严格IPV6 格式
   * @param {*} str
   * @returns
   */
  isIPv6Regxp: function (str) {
    const maskEndReg = /(:0+)$|(::)$|(\.0)$/;
    return this.isIPv6(str) && !maskEndReg.test(str);
  },
  /**
   * 验证IPV6 掩码
   * @param {*} str IPv6得地址/地址长度
   * @returns
   */
  isIPv6AndMask: function (str) {
    var ipv6 =
      /^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|1?\d\d?)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^:((:[\da-fA-F]{1,4}){1,6}|:)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$|^([\da-fA-F]{1,4}:){6}:(\/([1-9]?\d|(1([0-1]\d|2[0-8]))))?$/;
    return ipv6.test(str);
  },
  /**
   * 校验是否IPv6网络ID
   * @param {*} str
   */
  isIpv6Hint: function (str) {
    return /^[0-9a-fA-F]{1,4}$/.test(str);
  },
  /**
   * 校验本地链路地址
   * @param {*} v ipV6地址
   * @returns
   */
  isLinkLocal: function (v) {
    let _firstAddr16 = '';
    if (v.includes('::')) {
      let _first = v.split('::')[0];
      _firstAddr16 = _first.includes(':') ? _first.split(':')[0] : _first;
    } else {
      _firstAddr16 = v.split(':')[0];
    }
    let _firstAddr2 = parseInt(_firstAddr16, 16).toString(2);
    let _firstAddrRight = parseInt('fe80', 16).toString(2);
    if (_firstAddr2.length < 16) {
      return false;
    } else {
      if (_firstAddr2.slice(0, 10) !== _firstAddrRight.slice(0, 10)) {
        return false;
      }
    }
    return true;
  },
  checkIpOrIprange(ip) {
    if (ip.indexOf('-') > 0) {
      var ipArr = ip.split('-');
      return this.checkIp(ipArr[0]).result && this.checkIp(ipArr[1]).result;
    } else {
      return this.checkIp(ip).result;
    }
  },
  //校验IP
  checkIp(value) {
    if (
      !/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/i.test(
        value
      )
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule4'),
      };
    }
    return { result: true };
  },
  // eWeb上的检测IP，是否整合？
  checkIpOnEweb(value) {
    if (
      !/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/.test(
        value
      )
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule4'),
      };
    }
    return { result: true };
  },
  // 校验IP网段
  checkIpSegment(value) {
    if (
      !/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([0-9]|[1-2][0-9]|3[0-2])$/.test(
        value
      )
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule10'),
      };
    }
    return { result: true };
  },
  // 校验路由ID
  checkRId(value) {
    if (
      !/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/i.test(
        value
      )
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule4'),
      };
    }
    return { result: true };
  },
  //校验Mac
  checkMac(value) {
    let unicastPattern = /^[a-fA-F0-9]{1}[1,3,5,7,9,b,d,f]{1}.*$/;
    if (
      !/^([a-fA-F0-9]{4}\.){2}([a-fA-F0-9]{4})$/i.test(value) &&
      !/^([a-fA-F0-9]{2}:){5}([a-fA-F0-9]{2})$/i.test(value)
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule5'),
      };
    }
    if (unicastPattern.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule9'),
      };
    }
    return { result: true };
  },

  //校验Mac
  checkMac1(value) {
    let unicastPattern = /^[a-fA-F0-9]{1}[1,3,5,7,9,b,d,f]{1}.*$/;
    if (!/^([a-fA-F0-9]{4}\.){2}([a-fA-F0-9]{4})$/i.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule8'),
      };
    }
    if (unicastPattern.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule9'),
      };
    }
    return { result: true };
  },
  //校验整网密码格式是否规范
  checkEnetPwd(value) {
    //不能包含中文、全角字符、问号和空格 不能全数字 不能全字母 不能包含admin
    if (
      /^[1-9]+$/g.test(value) ||
      /^[a-zA-Z]+$/g.test(value) ||
      /admin/.test(value) ||
      /[\u4E00-\u9FA5\uFF00-\uFFFF?\s]/.test(value) ||
      value.length < 8 ||
      value.length > 31
    ) {
      return false;
    }

    let count = 0;

    if (/[1-9]/g.test(value)) {
      count++;
    }

    if (/[a-z]/g.test(value)) {
      count++;
    }

    if (/[A-Z]/g.test(value)) {
      count++;
    }

    if (/[`~!@#$%^&*()_+=|[\]{}.;:'<>]/.test(value)) {
      count++;
    }

    if (count >= 3) {
      return true;
    } else {
      return false;
    }
  },
  /**
   * 判断电话号码
   * @param {*} phone
   * @returns
   */
  checkPhone(phone) {
    if (process.env.VUE_APP_MACC_ENV == 'INTL') {
      return /^[0-9+\-]+$/.test(phone) && phone.length <= 25; //国际电话号码
    } else {
      return /^1[3|4|5|7|8|9][0-9]\d{8}$/.test(phone);
    }
  },
  //校验掩码
  checkMask(mask) {
    var reg =
      /^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)$/;
    return reg.test(mask);
  },
  //校验掩码(支持32位掩码:255.255.255.255)
  checkMask2(mask) {
    var reg =
      /^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(255|254|252|248|240|224|192|128|0)$/;
    return reg.test(mask);
  },
  rangeByteLength: function (value, range) {
    const len = encodeURI(value).split(/%..|./).length - 1;
    return len >= parseInt(range[0], 10) && len <= parseInt(range[1], 10);
  },
  //校验数值范围（只能整数）
  checkRangeNum(value, min, max) {
    let integerRegex = /^-?[0-9]+$/;
    if (!integerRegex.test(value)) {
      return false;
    }
    return parseInt(value) >= parseInt(min) && parseInt(value) <= parseInt(max);
  },

  //校验数值范围（允许整数）
  checkRangeNumDecimals(value, min, max) {
    let integerRegex = /^-?\d*\.?\d+$/;
    if (!integerRegex.test(value)) {
      return false;
    }
    return (
      parseFloat(value) >= parseFloat(min) &&
      parseFloat(value) <= parseFloat(max)
    );
  },

  // 验证时间格式
  checkEffectivePeriodTimeNew(value) {
    if (!/^\d{4}-\d{1,2}-\d{1,2}$/.test(value)) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule6'),
      };
    }
    return {
      result: true,
    };
  },

  // 检验密码
  checkPassword(value) {
    if (
      !/^[a-zA-Z0-9@<=>_\-[\]!#$*().]+$/.test(value) ||
      value.length < 6 ||
      value.length > 31
    ) {
      return {
        result: false,
        msg: i18nRender('validateTools.formatRule7'),
      };
    }
    return {
      result: true,
    };
  },
  //校验AllowVlan
  checkAllowVlan(value) {
    if (value == '') {
      return true;
    }

    // re = new RegExp(/^\d{1,4}((,|-)\d{1,4})*$/g);
    if (!/^\d{1,4}((,|-)\d{1,4})*$/g.test(value)) {
      //validator.openTip(field, '只允许数字，-及英文逗号');
      return false;
    }
    var allowVlan = value.split(',');
    var i = 0;
    for (i; i < allowVlan.length; i++) {
      var startEnd = allowVlan[i].split('-');
      //j = 0;
      if (1 == startEnd.length) {
        if (
          !/^([1-9][0-9]{0,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-4])$/.test(
            startEnd[0]
          )
        ) {
          return false;
        }
      } else if (2 == startEnd.length) {
        //for (j; j < startEnd.length; j++)
        if (
          !(
            /^([1-9][0-9]{0,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-4])$/.test(
              startEnd[0]
            ) &&
            /^([1-9][0-9]{0,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-4])$/.test(
              startEnd[1]
            ) &&
            parseInt(startEnd[0]) < parseInt(startEnd[1])
          )
        ) {
          return false;
        }
      } else if (startEnd.length > 2) {
        return false;
      }
    }
    return true;
  },
  /**
   * 校验IP和mask
   * @param {*} ip
   * @param {*} mask
   * @returns
   */
  checkIpMask(ip, mask) {
    var ipRegexp =
      /^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)$/;
    var _isIp = ipRegexp.test(ip);
    if (!_isIp) {
      return false;
    }
    var _ipArr = ip.split('.');
    if (
      _ipArr[3] == 0 ||
      _ipArr[0] == 0 ||
      _ipArr[0] == 127 ||
      parseInt(_ipArr[0]) >= 224
    ) {
      return false;
    }

    if (!mask) return false;
    var n = this.ipToLong(ip) & ~this.ipToLong(mask);
    if (n === 0) {
      return false;
    }
    var m = (this.ipToLong(ip) + 1) & ~this.ipToLong(mask);
    if (m === 0) {
      return false;
    }

    return true;
  },
  ipToLong(ipstr) {
    let iplong;
    let ipArr = new Array();
    ipArr = ipstr.split('.');
    iplong =
      (ipArr[0] << 24) +
      (ipArr[1] << 16) +
      (ipArr[2] << 8) +
      parseInt(ipArr[3], 10);
    return iplong;
  },
  /**
   * 整型转换成IP地址
   *
   * @param {Long}
   *            iplong 待转换的整数.
   * @return {String} 返回IP格式的地址
   *
   */
  longToIp: function (iplong) {
    let ips = [
      parseInt((iplong >> 24) & 0xff),
      parseInt((iplong >> 16) & 0xff),
      parseInt((iplong >> 8) & 0xff),
      parseInt(iplong & 0xff),
    ];
    return ips.join('.');
  },

  //校验是否是域名(不允许输入IP)
  checkDomain(url) {
    const donameRex =
      /^(?=^.{3,255}$)(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/;
    if (!donameRex.test(url)) {
      return false;
    }
    return true;
  },

  /**
   * @description: 判断是否emoji字符
   * @param {*} char
   * @return {*}
   */
  isEmojiCharacter(char) {
    // emoji范围大致在U+1F600到U+1F64F（表情符号）
    // 以及U+1F300到U+1F5FF（其他符号和象形图）
    // 还有更多范围，这里简化处理，实际可能需要更全面的范围检查
    //     \u{1F600}-\u{1F64F}：人脸表情
    // \u{1F300}-\u{1F5FF}：自然、食物和活动相关的表情
    const regex = /[\u{1F600}-\u{1F64F}|\u{1F300}-\u{1F5FF}]/gu;
    return regex.test(char);
  },

  // ------海外校验方法-----
  ruleRegex: /^(.+?)\[(.+)\]$/,
  //  数字型
  numericRegex: /^[0-9]+$/,
  // 整型
  integerRegex: /^\\-?[0-9]+$/,
  decimalRegex: /^\\-?[0-9]*\.?[0-9]+$/,
  // 正整数且不能为0开头的整数，如：0,02
  positiveIntegerRegex: /^[1-9]\d*$/,
  // 邮箱
  emailRegex:
    /^(([^$%=+￥<>()\\[\]\\.,;:\s@"]+(\.[^<>()\\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
  // 字母
  alphaRegex: /^[a-z]+$/i,
  // 字母数字
  alphaNumericRegex: /^[a-z0-9]+$/i,
  alphaDashRegex: /^[a-z0-9_\\-]+$/i,
  // 字母数字下划线
  alphaNumericUnderscoreRegex: /^[a-z0-9_]+$/i,
  // 字母数字下划线空格
  alphaNumericUnderscoreBlankRegex: /^[a-z0-9_\s]+$/i,
  naturalRegex: /^[0-9]+$/i,
  naturalNoZeroRegex: /^[1-9][0-9]*$/i,
  ipRegex:
    /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
  uuidRegex:
    /[\da-fA-F]{8}\\-[\da-fA-F]{4}\\-[\da-fA-F]{4}\\-[\da-fA-F]{4}\\-[\da-fA-F]{12}/,
  uuidNoRegex: /[\da-fA-F]{32}/,
  base64Regex: /[^a-zA-Z0-9\\/\\+=]/i,
  numericDashRegex: /^[\d\-\s]+$/,
  pwdStrengthRegex:
    /^(?![a-zA-z]+$)(?!\d+$)(?![`~!@#\\$%\\^\\&\\*\\(\\)_\\+<>\\?:"\\{\\},\\.\\\\/;'\\[\]\\-]+$)[a-zA-Z\d`~!@#\\$%\\^\\&\\*\\(\\)_\\+<>\\?:"\\{\\},\\.\\\\/;'\\[\]\\-]+$/,
  pwdEwebRegex_EG: /[\u4E00-\u9FA5\uFF00-\uFFFF?]/,
  urlRegex_CDN:
    /^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\\/]))?$/,
  urlRegex:
    /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)/,
  urlRegexIp:
    /https?:\/\/(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\\:([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])){0,1}(\/([-a-zA-Z0-9@:%_\\+.~#?&//=]*))*$/,
  urlRegexNoHttp:
    /[-a-zA-Z0-9@:%._\\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)/,
  domainRegex:
    /^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?$/,
  specialRegex:
    /[`~\-!@#$^&*()=|{}':;',\\[\].<>\\/?~！@#￥……&*（）——|{}【】‘；：”“’。，、？]/,
  dateRegex: /\d{4}-\d{1,2}-\d{1,2}/,
  // MAC格式 XXXX.XXXX.XXXX
  macRegex: /^([0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4})$/,
  // MAC格式 XX:XX:XX:XX:XX:XX
  macRegex2: /^([a-fA-F0-9]{2}:){5}([a-fA-F0-9]{2})$/,
  colorRegex: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,
  netMaskRegex:
    /^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)$/,
  ipv6Regex:
    /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/,
  deviceNameRegex: /^[\w\u4E00-\u9FA5\-\\@\\#]+$/,
  passwordRegex: /^[a-zA-Z0-9@<=>_\-[\]!#$*().]+$/,
  // -----------------
};

export { ValiDateTools };
